import requests
from entity.Goods import Goods


def getGoodsData():
    goodsList = []
    url = 'https://hq.sinajs.cn/list=AU0,M0,J0,RB0,C0,CU0,FG0'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36'
    }
    resp = requests.get(url=url, headers=headers)
    respList = resp.text.split(";")

    for r in respList:
        dataStr = r.replace("\n", "").split(",")
        if len(dataStr) > 7:
            goodsList.append(dataStr[6])

    goods = Goods(goodsList[0], goodsList[1], goodsList[2], goodsList[3], goodsList[4], goodsList[5], goodsList[6])
    return goods

